import threading
import time

class FooBar():
   def __init__(self,n):
       self.n = n

   def foo(self):
       for i in range(self.n):
           print('foo', end='')
           time.sleep(0.01)

   def bar(self):
       for i in range(self.n):
           print('bar', end='')
           time.sleep(0.01)

a=FooBar(2)
t1=threading.Thread(target=a.foo)
t2=threading.Thread(target=a.bar)
t1.start()
t2.start()